--- %%NOBANNER%% -->
/*-------------------<-- Start of Description-->---------------------\
| List the datasets, views and catalogs under the libnames. |
|---------------------<-- End of Description-->----------------------|
|--------------------------------------------------------------------|
|-----------<-- Start of Files or Arguements Needed-->---------------|
| Arguments: |
| libname - Name of the library; |
| worklib: the output _libdir will saved to the working directory.|
|-----------------<-- End of Arguements Needed-->--------------------|
|--------------------------------------------------------------------|
|------------------<-- Start of Files Created-->---------------------|
| Example: %libdir(libname="attest", outdata=libcnts); |
| Usage: %libdir(libname=, outdata=); |
\-------------------<-- End of Files Created-->---------------------*/
%macro libdir/parmbuff;
/*--------------------------------------------\
| Copy Right: Duo Zhou; |
| Created: 10-15-2001 9:20pm; |
| Purpose: List all objects under the lib |
| reference; |
\--------------------------------------------*/
%local num _i_ _tmplast_;
%let _tmplast_=&syslast;
%let libuff=%qscan(&syspbuff,1,%str((),));
%let outbuff=%qscan(&syspbuff,2,%str((),));
%let linesize = %SYSFUNC(GETOPTION(linesize));
%if (%index(%quote(&syspbuff),%quote(=))) %then %do;
%if (%index(%quote(&libuff),%quote(=))) %then %do;
%if (%index(%quote(%upcase(%sysfunc(compress(%quote(&libuff))))),%quote(LIB=)))
or (%index(%quote(%upcase(%sysfunc(compress(%quote(&libuff))))),%quote(LIBNAME=)))
or (%index(%quote(%upcase(%sysfunc(compress(%quote(&libuff))))),%quote(LIBREF=))) %then %do;
%let libname=%qscan(&libuff,2,%str(=));
%if (%index(%quote(&outbuff),%quote(=))) %then %do;
%if (not %index(%quote(%upcase(%sysfunc(compress(%quote(&outbuff))))),%quote(DATA=))) %then %do;
%put ==> Alert! Keyword parameter "%qscan(&outbuff,1,%str(=))" is not defined!;
%end;
%else %do;
%let outdata=%qscan(&outbuff,2,%str(=));
%end;
%end;
%else %do;
%let outdata=&outbuff;
%end;
%end;
%else %if (%index(%quote(%upcase(%sysfunc(compress(%quote(&libuff))))),%quote(DATA=))) %then %do;
%let outdata=%qscan(&libuff,2,%str(=));
%if (%index(%quote(&outbuff),%quote(=))) %then %do;
%if (not %index(%quote(%upcase(%sysfunc(compress(%quote(&outbuff))))),%quote(LIB=)))
and (not %index(%quote(%upcase(%sysfunc(compress(%quote(&outbuff))))),%quote(LIBNAME=)))
and (not %index(%quote(%upcase(%sysfunc(compress(%quote(&outbuff))))),%quote(LIBREF=)))
%then %do;
%put ==> Alert! Keyword parameter "%qscan(&outbuff,1,%str(=))" is not defined!;
%end;
%else %do;
%let libname=%qscan(&outbuff,2,%str(=));
%end;
%end;
%else %do;
%let libname=&outbuff;
%end;
%end;
%else %put ==> Alert! Keyword parameter "%qscan(&libuff,1,%str(=))" is not defined!;
%end;
%else %if (%index(%quote(&outbuff),%quote(=))) %then %do;
%if (%index(%quote(%upcase(%sysfunc(compress(%quote(&outbuff))))),%quote(LIB=)))
or (%index(%quote(%upcase(%sysfunc(compress(%quote(&outbuff))))),%quote(LIBNAME=)))
or (%index(%quote(%upcase(%sysfunc(compress(%quote(&outbuff))))),%quote(LIBREF=))) %then %do;
%let libname=%qscan(&outbuff,2,%str(=));
%let outdata=&libuff;
%end;
%else %if (%index(%quote(%upcase(%sysfunc(compress(%quote(&outbuff))))),%quote(DATA=))) %then %do;
%let libname=&libuff;
%let outdata=%qscan(&outbuff,2,%str(=));
%end;
%else %do;
%put ==> Alert! Keyword parameter "%qscan(&outbuff,1,%str(=))" is not defined!;
%end;
%end;
%end;
%else %do;
%let libname=&libuff;
%let outdata=&outbuff;
%end;
%if (%quote(&libname) eq) %then %do;
%let libname=work;
%end;
%let libname=%sysfunc(dequote(&libname));
%if (%index(%sysfunc(pathname(&libname)), %quote(\)) or
%index(%sysfunc(pathname(&libname)), %quote(/))) %then %do;
proc datasets library=&libname memtype=ALL;
contents out=work._temp1(keep=memname memtype engine nobs varnum name sorted sortedby nodupkey noduprec modate) data=_all_ noprint;
run;
proc sort data=_temp1; by memname sorted sortedby; run;
data _libdir(keep=memname engine nobs nvars sorted nodupkey noduprec sortvar);
retain memname engine nobs nvars sorted nodupkey noduprec sortvar;
set _temp1 end=final;
by memname sorted sortedby;
length sortvar $2000.;
retain sortvar nvars;
if first.memname then do;
sortvar=' ';
nvars=1;
end;
if not missing(sortedby) then do;
sortvar=compbl(sortvar)||name;
end;
if nvars0 %then %do;
proc print data=_libdir label;
title "%center(%initcaps([%trim(%left(&libname))] Library Dir))";
run;
%if &outdata ne %then %do;
data &outdata;
set _libdir;
run;
%end;
%else %let syslast=&_tmplast_;
proc sql; drop table _temp1; drop table _libdir; quit; run;
%end;
%else %put There is no datasets in the library "&libname".;
%mend libdir;